<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function trottle(fn, daley) {
        var starttime = new Date().getTime();
        return function () {
          var endtime = new Date().getTime();

          if ((endtime - starttime) / 1000 > daley) {
            fn();
            starttime = new Date().getTime();
          }
        };
      }

      document.onmousemove = trottle(function () {
        console.log("111");
      }, 1);
    </script>
  </body>
</html>
